#ifndef __GND_SERVICE_TASKMANAGER_H__
#define __GND_SERVICE_TASKMANAGER_H__

#include <list>
#include <sigc++/signal.h>

#include "Service.h"


namespace Gnodroid {

    class Task;
    enum class TaskState;

    class ServiceTaskmanager :
        public Service
    {
    public:
        ServiceTaskmanager();
        void start();
        void stop();

        Task* getTaskById(long id);

        sigc::signal<void, long>
        signalTaskAdded();

        /**
         * @brief taskInstallApp 启动一个安装App的任务
         * @param apkPath Apk文件的路径
         * @return task的唯一ID, 0 false
         */
        long
        taskInstallApp(std::string apkPath);

        long
        taskUninstallApp(std::string appPid);

        long
        taskExportApp(std::string appPid, std::string destPath);



    protected:
        sigc::signal<void, long> m_signalTaskAdded;

    private:
        std::list<Task*> m_lsTask;

        /**
         * @brief __finishTask 当任务完成时把任务从列表中移除
         * @param id
         * @param state
         */
        void __finishTask(long id, TaskState state);


    };

}


#endif
